<script setup>
import { onLaunch, onPageNotFound } from '@dcloudio/uni-app'
import { useStore } from '@/store'
import { TOKEN } from '@/assets/js/config'
const store = useStore()
onLaunch(() => {
  let appHide = false
  uni.onAppShow(() => {
    if (uni.getStorageSync(TOKEN) && !appHide) {
      appHide = false
      console.log('==============')
      console.log('我又出现啦！！！！！')
      const setProfile = uni.getStorageSync('setProfile')
      store.commit('setProfile', setProfile)
      uni.switchTab({
        url: 'home/index'
      })
    }
  })
  uni.onAppHide(() => {
    console.log('++++++++++++++++')
    console.log('我消失啦！！！！！')
    appHide = true
  })
})
onPageNotFound(() => {
  uni.redirectTo({
    url: '/pages/error'
  })
})
</script>

<style lang="scss">
@import "@/assets/styles/common.scss";
</style>
